package com.atguigu.tingshu.album.api;

import com.alibaba.fastjson.JSONObject;
import com.atguigu.tingshu.album.mapper.BaseCategory2Mapper;
import com.atguigu.tingshu.album.service.BaseCategoryService;
import com.atguigu.tingshu.common.result.Result;
import com.atguigu.tingshu.common.result.ResultCodeEnum;
import com.atguigu.tingshu.model.album.*;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;


@Tag(name = "分类管理")
@RestController
@RequestMapping(value = "/api/album/category")
@SuppressWarnings({"all"})
public class BaseCategoryApiController {

    @Autowired
    private BaseCategoryService baseCategoryService;


    //	/api/album/category/getBaseCategoryList  GET

    /**
     * 获取专辑分类列表
     * @return 返回Map的List集合
     */
    @Operation(summary = "获取专辑分类列表")
    @GetMapping("/getBaseCategoryList")
    public Result getBaseCategoryList() {

       List<JSONObject> categoryList  = baseCategoryService.getBaseCategoryList();
        return Result.ok(categoryList);

    }

    /* /api/album/category/findAttribute/{category1Id} */
    @Operation(summary = "获取属性数据")
    @GetMapping("/findAttribute/{category1Id}")
    public Result findAttribute(@PathVariable("category1Id") Long category1Id) {

        List<BaseAttribute> attributeList = baseCategoryService.findAttribute(category1Id);
        return Result.ok(attributeList);

    }


}

